Fix env overrides for optional scalar config values#5796
Conversation
|
Hi @preko-p, thank you for the contribution! |
|
Thanks, yes. A manual check for this fix would be: export DSPACE_REST_BASEURL=https://api.example.org/server
export DSPACE_REST_SSRBASEURL=http://internal-rest:8080/server
export DSPACE_MATOMO_TRACKERURL=https://analytics.example.org/matomo.php
npm run start:prodAfter the server has started, inspect the generated client config: cat dist/browser/assets/config.json | jq ".rest.baseUrl, .matomo.trackerUrl, .rest.ssrBaseUrl"Expected result:
The regression comparison is to run the same env vars on For |
References
Description
Environment variable overrides only walked config keys that were already present and non-empty in the merged config object. Valid optional scalar config settings with empty or absent defaults, such as
matomo.trackerUrlandrest.ssrBaseUrl, could therefore ignore their correspondingDSPACE_*environment variables unless a placeholder default was added.This PR extracts the environment override logic into a focused helper and adds a bounded supplemental map for optional scalar config leaves that cannot be discovered by the runtime object walk.
Instructions for Reviewers
List of changes in this PR:
matomo.trackerUrlviaDSPACE_MATOMO_TRACKERURLrest.baseUrlviaDSPACE_REST_BASEURLrest.ssrBaseUrlviaDSPACE_REST_SSRBASEURLDSPACE_REST_SSRBASEURLhandling inconfig.server.tsfor compatibility.DefaultAppConfig.DSPACE_*names;Scope note: this is intentionally a scalar-only fix for optional config leaves that cannot be discovered from the runtime object shape. It does not attempt to infer TypeScript interfaces at runtime or parse arrays/objects from environment variables.
Verification performed locally with Node
v22.17.1andnpm@10.9.4:Results:
7 SUCCESS0 errorswith existing repo-wide warningsgit diff --check: no whitespace errorsChecklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.